<?php /*a:4:{s:63:"D:\work\web\write_play_1\application\admin\view\good\index.html";i:1557542365;s:66:"D:\work\web\write_play_1\application\admin\view\layout\common.html";i:1555052965;s:73:"D:\work\web\write_play_1\application\admin\view\layout\public\header.html";i:1556096124;s:73:"D:\work\web\write_play_1\application\admin\view\layout\public\footer.html";i:1555384519;}*/ ?>
 <?php use app\admin\model\User;
 		$uid = cookie('uid');
       $user = User::where('id',$uid)->find();
       
       
 ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
    <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>高高的商城</title>
  <script type="text/javascript" src="/static/layui-v2.4.5/layui//layui.js"></script>
	<link rel="stylesheet" type="text/css" href="/static/layui-v2.4.5/layui//css/layui.css" />
	<script type="text/javascript" src="/static/js/jquery-3.3.1.min.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo" onclick="window.location.href='/'" onmouseover="this.style.cursor='pointer'">高高的商城</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
   <!--  <?php if(app('app\\common\\BaseController')->isAdmin): ?>}
    <ul class="layui-nav layui-layout-left" lay-filter="nav">
     
      <li class="layui-nav-item"><a href="111">商品管理</a></li>

      <li class="layui-nav-item">
        <a href="javascript:;">其它系统</a>
        <dl class="layui-nav-child">
          <dd><a href="">邮件管理</a></dd>
          <dd><a href="">消息管理</a></dd>
          <dd><a href="">授权管理</a></dd>
        </dl>
      </li>
    </ul>
    <?php endif; ?> -->
    <!-- <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
         
        <?php echo htmlentities($user->mobile); ?>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="/user/<?php echo htmlentities($uid); ?>">基本资料</a></dd>
          <dd><a href="">安全设置</a></dd>
          <dd><a href="/logout">退出</a></dd>
     
        </dl>
      </li>
      
    </ul> -->
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="nav">
        <li class="layui-nav-item" >
          <a class="" href="javascript:;">预留</a>
          <dl class="layui-nav-child">
            <dd><a href="/admin/test">测试</a></dd>
            <dd><a href="javascript:;">列表二</a></dd>
            <dd><a href="javascript:;">列表三</a></dd>
            <dd><a href="">超链接</a></dd>
          </dl>
        </li>
   
        <li class="layui-nav-item">
          <a href="/admin/user">用户</a>
          
        </li>
      
        <li class="layui-nav-item"><a href="/admin/role">权限</a></li>
        <li class="layui-nav-item"><a href="/admin/good">商品管理</a></li>
        <li class="layui-nav-item"><a href="/admin/category">商品分类</a></li>
      </ul>
    </div>
  </div>
  <div class="layui-body">

 <?php use app\admin\model\CateGory; ?>
<style type="text/css">
	table img{
		width: 50px;
		height: 50px;
		position: absolute;
		margin-top: -10px;
	}
	.layui-table-cell{
		overflow: visible;

	}

</style>
<div style="padding: 15px;">
<a class="layui-btn"  href="/admin/good/addGood">添加商品</a>

<div id="table" style="width:100%"></div>
</div>
<script type="text/html" id="bar">

  <a class="layui-btn layui-btn-xs"  lay-event="edit">编辑</a>
 <a class="layui-btn layui-btn-danger layui-btn-xs"   lay-event="del">删除</a>
</script>

<script type="text/javascript">
	
	layui.use('table', function(){
  table = layui.table;

  tableobj = table.render({
    elem: '#table'
    ,url:'/admin/good/getInfo'
   
    ,cols: [
   	[
     // {field:'update_time', title: '更新时间',unresize:true}
      {field:'id',width:100, type:'normal', title: 'ID', }
      ,{field:'name',width:150,title: '商品名称'}
     ,{style:"height:68px;overflow:visible;",width:150,title: '商品图片',templet:function(data){
     	return "<img src='/upload/"+data.logo+"' />"
     }}
     ,{field:'price',width:100,title: '价格'}
     ,{field:'good_num',width:100,title: '库存'}
     ,{width:100,title: '分类',templet:function(data){
     	// return "<?php echo CateGory::getCategoryName("+data.category_id+"); ?>";
     	
     	return data.category_id;
     }}
 ,{field:'create_time',width:170,  title: '创建时间'}

     ,{field:'update_time', width:170, title: '更新时间'}
      ,{field:'active', title: '操作',toolbar: '#bar'}
    ]]


    ,page:{
    	layout:['prev','page','next','count','skip'],
    	prev:'上一页',
    	next:'下一页',
    	limit:5,

    }

     ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
     	
     	
     	return {
     		"code":res.code,
     		"count": res.total,
    		"data": res.good //解析数据列表
     	}

    }
  });
   table.on('tool()', function(obj){
    var data = obj.data;
  	if(obj.event === 'edit'){

      window.location.href = "/admin/good/edit/"+data.id;
    }
    if(obj.event === 'del'){

     layui.use('layer', function(){
     var layer = layui.layer;
       layer.confirm('确定要删除', {
        btn: ['确定', '取消'] //可以无限个按钮
       
      }, function(index, layero){
           $.get('/admin/good/del/'+data.id,function(res){
        
        window.location.href = "/admin/good"
      })
      }, function(index){
        return;
      });
  })
      
    }
  });

});
</script>

</div>
   </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>


</body>
    <script>
//JavaScript代码区域

layui.use('element', function(){
  var element = layui.element;

 
});
$(".layui-nav[lay-filter='nav'] a").each(function(){
	var path = window.location.pathname;

	if(path.indexOf($(this).attr('href')) != -1){
		$(this).addClass('layui-this');
	}

})

</script>
</html>